package de.idgard.android.addon.proxy.services.impl;

import android.content.Context;
import de.idgard.android.addon.proxy.services.ProxyService;

public final class ProxyServiceRegistry {

	private static ProxyServiceRegistry instance;

	private ProxyServiceRegistry() {

	}

	public static ProxyServiceRegistry instance() {
		if (instance == null) {
			instance = new ProxyServiceRegistry();
		}
		return instance;
	}

	public void resetContext(Context ctx) {
		init = false;
		((ProxyServiceImpl) proxyService).setContext(ctx);
	}

	private ProxyService proxyService;

	private boolean init = false;

	public void init(Context ctx) {
		if (init) {
			return;
		}
		proxyService = new ProxyServiceImpl();
		((ProxyServiceImpl) proxyService).setContext(ctx);
		init = true;
	}

	public ProxyService getProxyService() {
		return proxyService;
	}
}
